package com.happe.foodeasy.service.impl;

import com.happe.foodeasy.dao.CustomerDao;
import com.happe.foodeasy.normal.entity.Customer;
import com.happe.foodeasy.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by wubin on 2016-04-03.
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    private CustomerDao customerDao;

    @Override
    public boolean checkUserByName(String username) {
        Customer customer = customerDao.findOneByProperties("username", username);
        return customer == null;
    }

    @Override
    public void saveOneCustomer(Customer customer) {
        customer.setId(customerDao.getSequenceNextValue(Customer.CUSTOMER_ID_SEQUENCE_NAME));
        customerDao.save(customer);
    }

    @Autowired
    public void setCustomerDao(CustomerDao customerDao) {
        this.customerDao = customerDao;
    }
}
